<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>换购商品</title>
    <link rel="stylesheet" href="../assets/css/iconfont.css">
    <link rel="stylesheet" href="../assets/css/layui.css">
    <link rel="stylesheet" href="../assets/css/view.css"/>
    <link rel="stylesheet" href="../assets/css/admin.css"/>
    <link rel="stylesheet" href="../assets/css/style.css"/>
</head>
<body class="layui-view-body">
<div class="layui-content">
    <!--面包屑导航-->
    <div class="mianb">
        <div class="mblf layui-col-xs6 layui-col-md6">
            <i class="layui-icon">&#xe656;</i>
            <p>宠物管理 > <span>添加宠物</span></p>
        </div>
        <div class="mbrt layui-col-xs6 layui-col-md6">
            <a href="javascript:;" class="layui-btn layui-btn-normal" id="fabu">添加宠物</a>
        </div>
    </div>
    <!--面包屑导航-->
    <div class="layui-row">
        <div class="layui-card">
            <div class="layui-row" id="fill">
            </div>
            <!--分页-->
            <div id="page"></div>
            <!--分页-->
        </div>
    </div>
</div>
<script src="../assets/jquery.min.js"></script>
<script src="../assets/layui.all.js"></script>
<script>
    var element = layui.element;
    layui.use(['laypage', 'layer', 'jquery'], function () {
        var laypage = layui.laypage
            , layer = layui.layer
            , $ = layui.jquery;

        getPageCount();

        function getPageCount() {
            $.get("/getPageCount", {}, function (data) {
                laypage.render({
                    elem: 'page'
                    , count: data
                    , limit: 8
                    , limits: [8, 16, 24, 32]
                    , layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
                    , jump: function (obj, first) {
                        $.get("/getGoodsShow?page=" + obj.curr + "&limit=" + obj.limit, {}, function (result) {
                            $("#fill").children().remove();
                            for (var i = 0; i < result.data.length; i++) {
                                var n = "";
                                if (result.data[i].goodsStatus === 1) {
                                    n = "<span style=\"font-size:15px;color: green\">已上架</span>\n";
                                } else {
                                    n = "<span style=\"font-size:15px;color: red\">未上架</span>\n";
                                }
                                $("#fill").append("<div class=\"layui-col-sm4 layui-col-md3 spbox\">\n" +
                                    "                    <div class=\"spitem\">\n" +
                                    "                        <div class=\"spimg\" style=\"width: 230px;height: 180px\">\n" +
                                    "                            <img id=\"goodsImage\" style=\"width: auto;height: auto;max-width: 230px;max-height: 180px\"\n" +
                                    "                                 src=" + result.data[i].goodsImage + "/>\n" +
                                    "                        </div>\n" +
                                    "                        <div class=\"sptxt\">\n" +
                                    "                            <h3>" + result.data[i].goodsName + "</h3>\n" +
                                    "                            <p><i style=\"font-size:15px\"></i>价格：<span id=\"goodsPrices\" style=\"font-size:15px\"\n" +
                                    "                                                                      class=\"col-red\">" + result.data[i].goodsPrice + "</span>元\n" +
                                    "                            </p>\n" +
                                    "                            <p><i style=\"font-size: 14px\"></i>状态：" + n +
                                    "                            </p>\n" +
                                    "                        </div>\n" +
                                    "                    </div>\n" +
                                    "            </div>");
                            }
                        }, "json");
                    }
                });
            }, "json");
        }


    });

    //弹框
    $('#fabu').on('click', function () {
        layui.use('layer', function () {
            var layer = layui.layer;
            layer.open({
                type: 2,
                title: '宠物信息',
                fix: false,
                shadeClose: true,
                shade: 0.8,
                area: ['900px', '600px'],
                content: 'upload_view.html',
                end: function () {
                    window.location.reload();
                }
            });
        });
    })

</script>

</body>
</html>